// 处理用户登录逻辑
const db = require("../lib/db")
function userLogin(username,userpwd){
console.log(username,userpwd);
// 1.用户名不存在
// 2.密码错误
// 3.登录成功
return new Promise((resolve,reject)=>{
    let sql = "select * from user where userName = '"+username+"'";
db.querySql(sql).then(data=>{
    if(data.length==0){
        resolve(501)
    }else{
        if(data[0].userPassword==userpwd){
            resolve(data[0])
        }else{
            resolve(502)
        }
    }
})
})

}


module.exports=userLogin